{{- if .Values.kubeDns.clusterDomainAliases }}
---
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
metadata:
  name: d8-kube-dns-sts-pods-hosts-appender-webhook
  {{- include "helm_lib_module_labels" (list . (dict "app" "sts-pods-hosts-appender-webhook")) | nindent 2 }}
webhooks:
- name: sts-pods-hosts-appender-conversion.flant.com
  failurePolicy: Fail
  matchPolicy: Equivalent
  sideEffects: None
  timeoutSeconds: 30
  admissionReviewVersions:
  - v1
  clientConfig:
    service:
      name: d8-kube-dns-sts-pods-hosts-appender-webhook
      namespace: kube-system
      path: "/mutate"
      port: 443
    caBundle: {{ .Values.kubeDns.internal.stsPodsHostsAppenderWebhook.ca | b64enc }}
  objectSelector:
    matchExpressions:
    - key: statefulset.kubernetes.io/pod-name
      operator: Exists
  rules:
    - operations: [ "CREATE" ]
      apiGroups: [""]
      apiVersions: ["v1"]
      resources: ["pods"]
{{- end }}
